<?php

declare(strict_types=1);

namespace App\Chat\Controller;

use App\Chat\Annotation\ChatAuth;
use App\Chat\Constant\QuickTabConstant;
use App\Chat\Constant\UserTabConstant;
use App\Chat\Request\SettingConfigRequest;
use App\Chat\Service\TalkSettingConfigService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

#[Controller(prefix: 'ch/chat/config'),ChatAuth]
class TalkSettingConfigController extends ChatBaseController
{
    #[Inject]
    protected TalkSettingConfigService $service;

    /**
     * 获取配置信息
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getInfo')]
    public function getInfo(): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getInfo($this->request->all()));
    }

    #[PostMapping('save')]
    public function save(SettingConfigRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->save($request->all()) ? $this->success() : $this->error();
    }

    /**
     * 获取快捷语标签列表
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getQuickTabList')]
    public function getQuickTabList(): \Psr\Http\Message\ResponseInterface
    {
        return $this->success(QuickTabConstant::getOptions());
    }

    /**
     * 获取用户资料标签列表
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getUserTabList')]
    public function getUserTabList(): \Psr\Http\Message\ResponseInterface
    {
        return $this->success(UserTabConstant::getOptions());
    }
}